import { Tag } from "antd"
const formatDate = (dateNumber: number) => {
	const date = dateNumber + ""
	return date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6)
}
const commissionRebate = (newFormat: (arg: string) => string) => {
	const rebateRender = (num: number | string) => {
		if (num !== 0 && !num) return "-"
		return `${num}%`
	}
	const statusRender = (num: number | string) => {
		switch (+num) {
			case 0:
				return <Tag color="default">{newFormat("agent.not_set")}</Tag>
			case 1:
				return <Tag color="success">{newFormat("agent.effective")}</Tag>
			case 2:
				return <Tag color="error">{newFormat("agent.expired")}</Tag>
			case 3:
				return <Tag color="warning">{newFormat("agent.adjustment")}</Tag>
			default:
				return <>-</>
		}
	}
	const agentHeaderRender = (text: string) => {
		return (
			<div>
				<div>{text}</div>
				<div>{newFormat("funds.bonusReviewRecord.personal_rebate")}</div>
			</div>
		)
	}

	return {
		texasCommission: {
			title: newFormat("label.texasRebate"),
			dataIndex: "texasCommission",
			render: rebateRender,
			align: "center",
			width: 150
		},
		texasInsuranceCommission: {
			title: newFormat("label.texasInsurance"),
			dataIndex: "texasInsuranceCommission",
			render: rebateRender,
			align: "center",
			width: 150
		},
		valueAddedServiceCommission: {
			title: newFormat("label.valueAddedService"),
			dataIndex: "valueAddedServiceCommission",
			render: rebateRender,
			align: "center",
			width: 150
		},
		otherCommission: {
			title: newFormat("agent.other_commission"),
			dataIndex: "otherCommission",
			render: rebateRender,
			align: "center",
			width: 150
		},
		commisssionStatus: {
			title: newFormat("common.status"),
			dataIndex: "status",
			width: 150,
			render: statusRender,
			align: "center"
		},
		agentTexasRebate: {
			title: agentHeaderRender(newFormat("common.dxn_club")),
			dataIndex: "texasRebate",
			width: 150,
			render: rebateRender,
			align: "center"
		},
		actualPersonRebatePlatform: {
			title: agentHeaderRender(newFormat("common.game_video")),
			dataIndex: "actualPersonRebatePlatform",
			render: rebateRender,
			width: 150,
			align: "center"
		},
		sportsRebatePlatform: {
			title: agentHeaderRender(newFormat("common.game_sports")),
			dataIndex: "sportsRebatePlatform",
			render: rebateRender,
			width: 150,
			align: "center"
		},
		lotteryTicketRebatePlatform: {
			title: agentHeaderRender(newFormat("common.game_lottery")),
			dataIndex: "lotteryTicketRebatePlatform",
			render: rebateRender,
			width: 200,
			align: "center"
		},
		chessRebatePlatform: {
			title: agentHeaderRender(newFormat("common.game_poker")),
			dataIndex: "chessRebatePlatform",
			render: rebateRender,
			width: 200,
			align: "center"
		},
		esportsRebatePlatform: {
			title: agentHeaderRender(newFormat("common.game_e_sports")),
			dataIndex: "esportsRebatePlatform",
			render: rebateRender,
			width: 200,
			align: "center"
		},
		electronicRebatePlatform: {
			title: agentHeaderRender(newFormat("common.game_electronic")),
			dataIndex: "electronicRebatePlatform",
			render: rebateRender,
			width: 200,
			align: "center"
		},
		cycle: {
			title: newFormat("funds.fund_audit.settlement_cycle"),
			dataIndex: "cycle",
			width: 200,
			align: "center",
			render: (_text: any, record: any) => {
				return `${formatDate(record.cycleStartDate)} ${newFormat("label.to")} ${formatDate(record.cycleEndDate)}`
			}
		}
	}
}

export default commissionRebate
